<template>
  <div class="box">
    <div class="content">
      <!-- 面包屑组件 -->
      <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
        <span class="back" @click="goBack()">返回上一页</span>
      </el-breadcrumb>
      <!-- 一楼 -->
      <div class="f1" v-if="data">
        <div class="title">
          <p>{{ data.oderid }}</p>
          <h5
            :class="{
              dfk: data.status == '待反馈' || data.status == '未反馈',
              yfk: data.status == '已反馈',
              spz: data.status == '审批中',
              sptg: data.status == '审批通过',
              spjj: data.status == '审批拒绝',
              bhykl: data.status == '保函已开立',
              zcjx: data.status == '正常结项',
              yqjx: data.status == '逾期结项',
              yqx: data.status == '已取消',
            }"
          >
            {{ data.status }}
          </h5>
        </div>

        <!-- 产品信息 -->
        <div class="details">
          <div class="details-item">
            <div class="details-item-left">
              <ul style="width: 120px">
                <li>产品名称：</li>
                <li>金融机构：</li>
                <li>授信起始日期：</li>
              </ul>
              <div>
                <p style="cursor: pointer; display: flex; align-items: center">
                  <span>{{ data.productname }}</span>
                </p>
                <p style="width: 300px">
                  {{ getData(data.Funder) }}
                </p>
                <p style="width: 370px">
                  <span>{{ getDate(data.startdate) }}</span>
                </p>
              </div>
            </div>
            <div class="details-item-left">
              <ul>
                <li>申请日期：</li>
                <li>授信额度（元）：</li>
                <li>授信结束日期：</li>
              </ul>
              <div>
                <p>{{ getDate(data.inputdate) }}</p>
                <p
                  v-if="data.status === '审批中' || data.status === '审批拒绝'"
                >
                  -
                </p>
                <p v-else>{{ getArea(data.amount) }}</p>
                <p>
                  <span>{{ getDate(data.enddate) }}</span>
                </p>
              </div>
            </div>
          </div>
        </div>
      </div>
      <!-- 二楼 -->
      <div class="f2">
        <!-- 顶部标签 -->
        <div class="title">
          <h3>项目信息</h3>
          <!-- <h3 :class="{ active: row == 2 }" @click="row = 2">用信信息</h3> -->
        </div>
        <!-- 审批进度 -->
        <h2>项目进度</h2>
        <div class="schedule" v-if="findxmjd">
          <div class="schedule1">
            <img src="@/assets/image/组194.png" alt="" />
            <h1
              :class="{
                dfk: findxmjd.b == 'null',
              }"
            ></h1>
            <img
              v-if="findxmjd.b == 'null' || findxmjd.b == null"
              src="@/assets/image/组195.png"
              alt=""
            />
            <img v-else src="@/assets/image/组194.png" alt="" />
            <h1
              :class="{
                dfk: findxmjd.c == null,
              }"
            ></h1>
            <img
              v-if="findxmjd.c == 'null' || findxmjd.c == null"
              src="@/assets/image/组195.png"
              alt=""
            />
            <img v-else src="@/assets/image/组194.png" alt="" />
          </div>
          <div class="schedule2">
            <div
              class="state"
              :class="{
                jj: findxmjd.statu == '拒绝',
                yqx: findxmjd.statu == '已取消',
                yyq: findxmjd.statu == '已逾期',
                yfk: findxmjd.statu == '已放款',
              }"
              v-if="findxmjd.statu != 'null'"
            >
              {{ findxmjd.statu }}
            </div>
            <span>业务申请</span>
            <h2></h2>
            <span
              :class="{
                dfk: findxmjd.b == 'null',
              }"
              >授信审批</span
            >
            <h2></h2>
            <span
              :class="{
                dfk: findxmjd.c == null,
              }"
              >项目结项</span
            >
          </div>
          <div class="schedule3">
            <span>{{ findxmjd.a }}</span>
            <h3></h3>
            <span>{{ findxmjd.b == "null" ? "" : findxmjd.b }}</span>
            <h3></h3>
            <span>{{ findxmjd.c == null ? "" : findxmjd.c }}</span>
          </div>
        </div>
        <h2>申请信息</h2>
        <div class="details-item">
          <div class="details-item-left">
            <ul style="width: 140px; position: relative">
              <li>担保模式:</li>
              <li>担保起始日期：</li>
              <li>担保金额（元）：</li>
            </ul>
            <div>
              <p>{{ kjApplyInfo.guarantee }}</p>
              <p>{{ kjApplyInfo.guaranteedate }}</p>
              <p>{{ getArea(kjApplyInfo.guaranteeamount) }}</p>
            </div>
          </div>
          <div class="details-item-left">
            <ul style="width: 250px; position: relative">
              <li>当前财报年份：</li>
              <li>企业当前年度资产合计（元）：</li>
              <li>企业当期年度负债合计（元）：</li>
            </ul>
            <div>
              <p>{{ getData(kjApplyInfo.particularyear) }}</p>
              <p>{{ getArea(kjApplyInfo.currentasset) }}</p>
              <p>
                {{
                  kjApplyInfo.currentliabilities == null
                    ? "-"
                    : getAreas(kjApplyInfo.currentliabilities)
                }}
              </p>
            </div>
          </div>
        </div>
        <h2>申请资料</h2>
        <div class="table">
          <el-table
            :data="applyData"
            border
            highlight-current-row
            stripe
            :header-cell-style="{
              background: '#F1F5FF',
              color: '#4D4D4D',
            }"
          >
            <template v-slot:empty>
              <div>暂无数据</div>
            </template>
            <el-table-column prop="" label="序号" width="80" align="center">
              <template #default="scope">{{ scope.$index + 1 }}</template>
            </el-table-column>
            <el-table-column
              prop="name"
              label="资料名称"
              min-width="20%"
              align="center"
            >
            </el-table-column>
            <el-table-column label="操作" min-width="3%" align="center">
              <template #default="scope">
                <span
                  @click="examine(scope.$index, applyData)"
                  class="span1"
                  type="text"
                  size="small"
                >
                  查看
                </span>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <h2>合同信息</h2>
        <div class="table">
          <el-table
            :data="contractData"
            border
            highlight-current-row
            stripe
            :header-cell-style="{
              background: '#F1F5FF',
              color: '#4D4D4D',
            }"
          >
            <template v-slot:empty>
              <div>暂无数据</div>
            </template>
            <el-table-column
              prop=""
              label="序号"
              fixed
              width="80"
              align="center"
            >
              <template #default="scope">
                {{ scope.$index + 1 }}
              </template>
            </el-table-column>
            <el-table-column
              prop="conname"
              label="合同名称"
              min-width="9%"
              align="center"
              fixed
            >
            </el-table-column>
            <el-table-column
              prop="signday"
              label="签署时间"
              min-width="9%"
              align="center"
            >
            </el-table-column>
            <el-table-column
              label="操作"
              min-width="3%"
              align="center"
              fixed="right"
            >
              <template #default="scope">
                <span
                  class="span1"
                  type="text"
                  size="small"
                  @click="examineContract(contractData[scope.$index].filepath)"
                >
                  查看
                </span>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { myPostFetch } from "@/utils";
import {
  AreaDispose,
  dateDispose,
  dataDispose,
  AreaDisposes,
} from "@/utils/filters.js";
export default {
  data() {
    return {
      findxmjd: null,
      row: 1,
      id: "", //项目id
      data: null,
      kjApplyInfo: {},
      contractData: null,
      // 申请文件表格数据
      applyData: null,
    };
  },
  mounted() {
    // 获取地址栏中的id
    this.id = this.$route.query.id;
    this.findkj();
    this.getFindxmjd();
  },
  methods: {
    // 金额处理
    getArea(value) {
      return AreaDispose(value);
    },
    // 时间处理
    getDate(value) {
      return dateDispose(value);
    },
    // 数据处理 为空显示为 -
    getData(value) {
      return dataDispose(value);
    },
    getAreas(value) {
      return AreaDisposes(value);
    },
    // 项目进度
    async getFindxmjd() {
      let url = "/api/hubeibusienss/findxmjd";
      let params = {
        applyid: this.id,
      };
      let data = await myPostFetch(url, params);
      if (data.code == 100) {
        let date = data.data.b.split("@")[0];
        let b = data.data.b.split("@")[1];
        this.findxmjd = data.data;
        this.findxmjd.b = date;
        this.findxmjd.statu = b;
      }
    },
    // 获取详情 /api/hubeibusienss/findSXXQ
    async findkj() {
      let url = "/api/hubeibusienss/findSXXQ";
      let applyid = this.id;
      let params = {
        applyid: applyid,
      };
      let { data } = await myPostFetch(url, params);
      this.data = data;
      this.kjApplyInfo = data.kjApplyInfo;
      this.applyData = data.file;
      this.contractData = data.Contract;
    },
    // 返回上一页
    goBack() {
      this.$router.push("/projectCrossBorder");
    },
    // 返回产品列表
    goCrossBorder() {
      this.$router.push("/crossBorder");
      setTimeout(() => {
        this.$router.go(0);
      }, 500);
    },
    // 查看
    examine(index, data) {
      let filetype = data[index].filetype;
      let val = data[index];
      let imgUrlStr = val.path;
      if (
        filetype == "jpg" ||
        filetype == "png" ||
        filetype == "PNG" ||
        filetype == "JPG"
      ) {
        const a = document.createElement("a"); // 动态创建a标签，防止下载大文件时，用户没看到下载提示连续点击
        a.setAttribute("target", "_blank");
        a.href = val.path;
        a.click();
      } else {
        fetch(imgUrlStr).then((res) =>
          res.blob().then((blob) => {
            const a = document.createElement("a"), // 动态创建a标签，防止下载大文件时，用户没看到下载提示连续点击
              url = window.URL.createObjectURL(blob),
              filename = val.name;
            a.href = url;
            a.download = filename;
            a.click();
            window.URL.revokeObjectURL(url);
          })
        );
      }
    },
    // 查看合同
    examineContract(path) {
      const a = document.createElement("a"); // 动态创建a标签，防止下载大文件时，用户没看到下载提示连续点击
      a.setAttribute("target", "_blank");
      a.href = path;
      a.click();
    },
  },
};
</script>

<style lang="scss" scoped>
.box {
  box-sizing: border-box;
  padding-bottom: 50px;
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  // 返回上一页
  .back {
    position: absolute;
    cursor: pointer;
    left: 0px;
    font-size: 16px;
    color: #0a7be0;
    text-decoration: underline;
    user-select: none;
  }
  // 面包屑
  .breadcrumb {
    display: flex;
    align-items: center;
    height: 24px;
    .icon {
      margin: 0 10px 0 4px;
    }
    .span {
      font-size: 16px;
      font-family: Source Han Sans SC;
      font-weight: 400;
      color: #999999;
    }
  }

  .f1 {
    box-sizing: border-box;
    width: 100%;
    background: #fff;
    box-shadow: 0px 1px 10px 0px rgba(196, 196, 196, 0.15);
    // border-radius: 6px;
    margin: 15px 0 10px 0;
    padding: 20px 30px;
    // height: 240px;
    // overflow: auto;
    .title {
      display: flex;
      align-items: center;
      width: 100%;
      height: 24px;
      p {
        font-size: 20px;
        font-family: Source Han Sans SC;
        font-weight: 400;
        color: #333333;
      }
      h5 {
        @media only screen and (min-width: 1px) and (max-width: 900px) {
          display: none;
        }
        // width: 85px;
        box-sizing: border-box;
        padding: 0 10px;
        height: 18px;
        background: #3cb0ff;
        border-radius: 2px;
        font-size: 14px;
        font-family: Source Han Sans SC;
        font-weight: 400;
        color: #ffffff;
        text-align: center;
        line-height: 18px;
        margin-left: 8px;
        &.dfk {
          background: #f19149;
        }
        &.yfk {
          background: #ec6941;
        }
        &.spz {
          background: #48a0b8;
        }
        &.sptg {
          background: #48b8a7;
        }
        &.spjj {
          background: #ff6060;
        }
        &.bhykl {
          background: #13b5b1;
        }
        &.zcjx {
          background: #80c269;
        }
        &.yqjx {
          background: #448aca;
        }
        &.yqx {
          background: #556fb5;
        }
      }
      span {
        @media only screen and (min-width: 1px) and (max-width: 750px) {
          display: none;
        }
        font-size: 13px;
        margin-left: 50px;
        i,
        a {
          color: #0a7be0;
          text-decoration: underline;
          cursor: pointer;
        }
        .nactive {
          font-size: 14px;
          margin-right: 5px;
          color: #9999 !important;
        }
      }
    }
    // <!-- 产品详细信息开始 -->
    .details {
      width: 100%;
      margin-left: 10px 10px;
      .details-item {
        display: flex;
        width: 100%;
        .details-item-left {
          display: flex;
          // width: 25%;
          height: 100%;
          ul {
            width: 160px;
            height: 100%;
            font-size: 17px;
            font-family: Source Han Sans SC;
            font-weight: 400;
            color: #999999;
            // overflow: hidden;
            // white-space: nowrap;
            // text-overflow: ellipsis;
            li {
              margin-top: 20px;
              height: 30px;
              background-color: #fff;
            }
          }
          div {
            height: 100%;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
            z-index: 99;
            p {
              height: 30px;
              font-size: 16px;
              font-family: Source Han Sans SC;
              font-weight: 400;
              color: #4d4d4d;
              margin-top: 20px;
            }
          }
        }
      }
    }
  }
  .f2 {
    overflow: hidden;
    width: 100%;
    // height: 100%;
    box-sizing: border-box;
    background: #ffffff;
    box-shadow: 0px 1px 10px 0px rgba(196, 196, 196, 0.15);
    // border-radius: 6px;
    padding: 20px 20px;
    scroll-behavior: smooth;
    overflow: auto;
    .title {
      display: flex;
      align-items: center;
      width: 100%;
      height: 60px;
      z-index: 99;
      h3 {
        height: 32px;
        width: 75px;
        line-height: 28px;
        text-align: center;
        box-sizing: border-box;
        margin-left: 15px;
        font-size: 16px;
        font-family: Source Han Sans SC;
        font-weight: 400;
        color: #838383;
        cursor: pointer;
        box-sizing: border-box;
        border-bottom: 2px solid #3f6ef2;
        color: #3f6ef2;
        // &.active {
        //   box-sizing: border-box;
        //   border-bottom: 2px solid #3f6ef2;
        //   color: #3f6ef2;
        // }
      }
    }
    .null {
      display: flex;
      flex-direction: column;
      align-items: center;
      width: 100%;
      height: 300px;
      img {
        width: 326px;
        height: 212px;
      }
      p {
        font-size: 13px;
        color: #666;
        margin-bottom: 8px;
        a {
          color: #0a7be0;
          cursor: pointer;
        }
        span {
          color: #0a7be0;
          text-decoration: underline;
          cursor: pointer;
        }
      }
    }
    .enquiry {
      display: flex;
      margin: 10px 15px;

      .enquiry-item {
        display: flex;
        width: 48%;
        height: 100%;
        ul {
          width: 170px;
          height: 100%;
          font-size: 15px;
          font-family: Source Han Sans SC;
          font-weight: 400;
          color: #999999;
          li {
            margin-top: 10px;
            height: 30px;
            background-color: #fff;
          }
        }
        div {
          width: 180px;
          height: 100%;
          margin-left: 15px;
          p {
            height: 30px;
            font-size: 15px;
            font-family: Source Han Sans SC;
            font-weight: 400;
            color: #4d4d4d;
            margin-top: 10px;
          }
        }
      }
    }
    h2 {
      font-size: 16px;
      font-family: Source Han Sans SC;
      font-weight: 400;
      color: #333;
      margin: 15px 15px 10px 15px;
    }
    // 项目进度
    .schedule {
      width: 100%;
      margin: 50px 0;
      .schedule1 {
        box-sizing: border-box;
        padding: 0 45px;
        display: flex;
        align-items: center;
        justify-content: space-evenly;
        width: 100%;
        height: 35px;

        img {
          width: 35px;
        }
        h1 {
          width: 250px;
          height: 1px;
          background: #3f6ef2;
          &.dfk {
            background: #a4a4a4;
          }
        }
      }
      .schedule2 {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: space-evenly;
        box-sizing: border-box;
        padding: 0 7px;
        width: 100%;
        height: 35px;
        h2 {
          width: 150px;
          height: 1px;
        }
        span {
          font-size: 17px;
          font-family: Source Han Sans SC;
          font-weight: 400;
          color: #3f6ef2;
          &.dfk {
            color: #a4a4a4;
          }
        }
        .state {
          box-sizing: border-box;
          padding: 0px 4px;
          display: flex;
          justify-content: center;
          justify-items: center;
          position: absolute;
          left: 54%;
          background: #22b556;
          opacity: 0.8;
          border-radius: 2px;
          font-size: 14px;
          font-family: Source Han Sans SC;
          font-weight: 400;
          color: #ffffff;
          &.jj {
            background: #fc6464;
          }
          &.yqx {
            background: #556fb5;
          }
        }
      }
      .schedule3 {
        display: flex;
        align-items: center;
        justify-content: space-evenly;
        width: 100%;
        height: 35px;
        h3 {
          width: 285px;
          height: 1px;
        }
        span {
          display: block;
          width: 350px;
          text-align: center;
          font-size: 14px;
          font-family: Source Han Sans SC;
          font-weight: 300;
          color: #8d93a1;
        }
      }
    }
    // 基本信息
    .details-item {
      display: flex;
      margin: 10px 15px;
      .details-item-left {
        display: flex;
        height: 100%;
        width: 600px;
        ul {
          width: 320px;
          height: 100%;
          font-size: 15px;
          font-family: Source Han Sans SC;
          font-weight: 400;
          color: #999999;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
          li {
            margin-top: 20px;
            height: 30px;
            background-color: #fff;
          }
        }
        div {
          width: 135px;
          height: 100%;
          margin-left: 15px;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
          z-index: 99;
          p {
            height: 30px;
            font-size: 15px;
            font-family: Source Han Sans SC;
            font-weight: 400;
            color: #4d4d4d;
            margin-top: 20px;
          }
        }
      }
    }
    // 表格
    .table {
      box-sizing: border-box;
      background-color: #fff;
      height: 100%;
      margin-top: 20px;
      margin-left: 10px;
      overflow: auto;
      .span {
        display: inline-block;
        // width: 0.1563rem;
        // height: 0.125rem;
        font-size: 15px;
        font-family: Source Han Sans SC;
        font-weight: 400;
        margin-right: 5px;
        color: #ccc;
        border-bottom: 1px solid #ccc;
        cursor: pointer;
        margin-right: 10px;
      }
      .span1 {
        display: inline-block;
        font-size: 15px;
        font-family: Source Han Sans SC;
        font-weight: 400;
        margin-right: 5px;
        color: #3f6ef2;
        border-bottom: 1px solid #3f6ef2;
        cursor: pointer;
      }
    }
  }
  .f2::-webkit-scrollbar {
    width: 5px;
    height: 5px;
    background-color: #fff;
  }

  .f2::-webkit-scrollbar-thumb {
    border-radius: 2px;
    background: rgba(36, 143, 172, 0.5);
  }
  .f1::-webkit-scrollbar {
    width: 5px;
    height: 5px;
    background-color: #fff;
  }

  .f1::-webkit-scrollbar-thumb {
    border-radius: 2px;
    background: rgba(36, 143, 172, 0.5);
  }
  // 弹出框
  .dialog-center {
    width: 90%;
    margin: 0 auto;
  }
  .dialog-footer {
    display: flex;
    justify-content: space-evenly;
    width: 70%;
    margin: 0 auto;
    .dialog-footer-bnt {
      width: 121px;
      height: 31px;
      color: #0a7be0;
      border: 1px solid #0a7be0;
      border-radius: 4px;
      background-color: #fff;
    }
    .btn2 {
      color: #fff;
      background-color: #0a7be0;
    }
  }
  .abc {
    width: 368px;
    .el-select {
      width: 100%;
    }
  }
  .el-form-item {
    margin-bottom: 15px;
    .file {
      font-size: 15px;
      margin-right: 10px;
      color: #0a7be0;
      text-decoration: underline;
      cursor: pointer;
    }
    .file1 {
      color: #999;
    }
  }
  // 弹出框
  .dialog-center {
    margin: 0 auto;
    width: 90%;
  }
  .dialog-footer {
    display: flex;
    justify-content: space-evenly;
    width: 70%;
    margin: 0 auto;
    .dialog-footer-bnt {
      width: 121px;
      height: 31px;
      color: #0a7be0;
      border: 1px solid #0a7be0;
      border-radius: 4px;
      background-color: #fff;
    }
    .btn2 {
      color: #fff;
      background-color: #0a7be0;
    }
  }
  .abc {
    width: 368px;
    .el-select {
      width: 100%;
    }
  }
}
.content {
  margin: 0 auto;
  position: relative;
  width: 960px;
}
/* 输入框样式  */
::v-deep(.el-input__inner) {
  box-sizing: border-box;
  width: 280px;
  height: 39px;
  font-size: 15px;
  border: 1px solid #e0e0e0;
  border-radius: 0px;
  padding: 10px 10px;
  color: #606266;
  outline: 0;
  line-height: 35px !important;
}
</style>
<style lang="scss">
/* 表格 */
.el-table {
  th.el-table__cell > .cell {
    font-size: 16px;
    font-weight: 400;
  }
  .cell {
    font-size: 16px;
  }
}
.el-table tr {
  height: 40px;
}
.el-table thead {
  height: 40px;
}
</style>
